package cn.xerllent.quartz.job;

import java.text.SimpleDateFormat;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import cn.xerllent.common.annotation.Log;
import cn.xerllent.system.service.LogService;
import lombok.extern.slf4j.Slf4j;


/**
 * 构建job,一定要继承org.springframework.scheduling.quartz.QuartzJobBean方法，
 * DataMap数据才会通过set注入bean实体内，继承org.quartz.Job参数无注入
 * */
@Slf4j
public class TestJob implements Job {
	
	@Autowired
	private LogService logService;
	
	private String a;
	

	public String getA() {
		return a;
	}


	public void setA(String a) {
		this.a = a;
	}

	/**
	 * 在此加切面aspect方法@Log("测试任务")  ，没用
	 * */
	//@Log("测试任务")
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {

        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String jobName = context.getJobDetail().getKey().toString();
        
        log.info(jobName + "任务开始执行：" + dateformat.format(System.currentTimeMillis()));
        // TODO 业务job1.job1
        log.info("------------a:"+a+"-------------------");
        cn.xerllent.system.entity.Log logg = logService.getById(5122L);
        log.info(logg.toString());
        log.info(jobName + "任务执行完成：" + dateformat.format(System.currentTimeMillis()));
	}
}
